﻿using System;

namespace Isaac.Joy.Identity.Web.DtCms.Models
{
    public class PageInfor
    {
        public PageInfor(int pageindex, int pagesize, int totalcount)
        {
            Index = pageindex;
            Size = pagesize;
            DataCount = totalcount;
        }

        /// <summary>
        /// 当前页索引
        /// </summary>
        public int Index { get; private set; }

        /// <summary>
        /// 每页数量
        /// </summary>
        public int Size { get; private set; }

        /// <summary>
        /// 数据总数量
        /// </summary>
        public int DataCount { get; private set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int PageCount
        {
            get
            {
                if (DataCount == 0) return 1;
                return (DataCount + Size - 1) / Size;
            }
        }

        /// <summary>
        /// 分页函数
        /// </summary>
        public Func<int, int, string> PageUrl { get; set; }
    }
}